﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;
using MarcatelHD.Models;
using System.DirectoryServices;
using System.Configuration;



namespace MarcatelHD.Models.Seguridad
{
    public class MVCRoleProvider : RoleProvider
    {
        private marcateldbEntities db = new marcateldbEntities();

        public override string[] GetRolesForUser(string username)
        {
            
            try
            {

                 

                IEnumerable<string> tblu = db.tblUsuarios.Where(m => m.Usuario == username).Select(m => m.tblRoles.Nombre);
                
                string[] RetVal = tblu.ToArray();
                
                return RetVal;                         
            }
            catch (Exception)
            {
                  return null;                
            }               
            
        }
        #region NoUsados
        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override string ApplicationName
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public override void CreateRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            throw new NotImplementedException();
        }

        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            throw new NotImplementedException();
        }

        public override string[] GetAllRoles()
        {
            throw new NotImplementedException();
        }



        public override string[] GetUsersInRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool IsUserInRole(string username, string roleName)
        {
            throw new NotImplementedException();
        }

        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override bool RoleExists(string roleName)
        {
            throw new NotImplementedException();
        }
        #endregion       
    }
}